General code cleanup - more idiomatic Ruby