Major cleanup and feature additions