optimizations to glow, fixed some compiler warnings, added comments to code