Update api.php

Fixes based on suggestions from issue #20