major code cleanup and more questions added