Added private functions and vars, make more secure