Added some goto to skip extraneous tests
Changed one liners into inline functions and added macro to delete copy-pasted code
Added a few options. Also, refactoring