bringing in changes from mangabey into this project