Some refactoring suggestions 

Sorry for the big delay.