Code tidy

split out the class for easier management going forward