Lot's of cleanup in pass4
Removed unused functions and variables