Update api code

fixes #29