Move prototype functions inside module
Move setup into init function
More refactoring, rename private functions