Cleaned some things up and added comments