tiny memory allocation improvements Contributed by Benoit Wiart (b.wiart at ubik-ingenierie.com). this closes #229 on github