Cleanups, and simplificaiton of some code.