Cleanup and simplification of code.