Major structural changes and cleanup v2