Implemented most functionality