added some suggestions from GUL; clean up code & implement suggestions