First round of extensive code quality improvements; more to come