cleaned up code, hopefully fixed startup bug, commented