Used prototypal inheritance and corrected a few bugs.