Added comments explaining the giant if/else block in step