code tidy

refactored and tidyed up code, also started implementing difrent
resilution support