Cleaned up file a bit, condensed some code