Code cleanup

moved all that __init__ cruft into a set of helper functions.