Removal of loads of old code, and cleaning up structure

Moved things into their right places, fixed a lot of style warnings, deleted old fashioned perception calling routines code.