Fixed a few silly bugs. Still not working
Wierd things are happening in the output which I can't trace to
any of my code, maybe a bit too soon to blame the AMOS api but I
just can't figure out what's going on.