Refactoring code for clarity

This is not yet ready...

Will be working on this first and later adding some navigation features.