cleaned up more code and changed a few things around