cleaned up some code and fixed some things