Refactored sigint and added comments and some control-flow stuff.