More formatting & cleanup
packed all functions into object func