cleaned up various sloppy code, still some left to do