made tiny fixes and cleaned up code a little