Cleanup and code reduction