Implemented most functionality.