Firstly, Welcome to the forum, and congrats, you're among the select few who's original post meets all the major criteria for a great start - legible schematic, coherent post that compiles (other than a missing .h file), and comprehensible textual statement of problem and desired help!
Others have given useful advice about your hardware. I concur on,
- buy a commercial relay board; if this is a prototype, use amazon cheapies, but if this is for a real application, buy something from a reputable source likely to have better quality relays. Ensure it has opto-iso protection for your CPU, with transistor/mosfet drive for the relay and good reverse-diode protection from the relay field collapse.
- if a prototype, yeah, change your contact sensing to using internal pullups and low-active logic; it'll do for short term. Again, if it's commercial, think about better input isolation, especially if it's not "all in a box" - if your inputs are exposed to other mechanical/electrical equipment's foibles, it's not dificult to arrange those contact inputs as drivers for optical isolation inbound, especially since you seem to have 24V available. Again, multi-input iso boards are available very cheaply, and without electromechanical relays, durability is less of a concern.
As for Serial input, read
As Serial input details are some of the most commonly rehashed and misunderstood problems we see here. If that doesn't get you on the straight-and-narrow, come back and ask your questions - on this thread please, don't start a new one, as the context will be lost.
Again, Welcome!