Cleaned up code structure and extension API.