Big clean up, few bug fixes snuck in