properly initalize atom properties
fix a few minor memory leaks
add a few comments