Moved some functions defined inside constructors to the corresponding prototypes