Removed nested defns and moved top level let bindings to defs