massive cleanup; re-organized code to be more gem-ish