some badly needed code beautification