Minor refactorings

I've made code more ruby idiomatic.