restructure the code.

Removed loads of unused features.