Support for choice of malloc/free etc

Allows std malloc/free to be overridden if ADT_MALLOC and ADT_FREE are
defined.
Also a few XXX comments added for things which should be fixed.