Code cleaned up further, next up, refactor and modularize