Cleaned up some things and added comments