Clean up server logic and add clean exit

This just adds some basic signal handing for exit the server, and cleans up the server logic to make things more extensible as we add more features.