Fix various bugs in amon api.