Minor code overhaul