miscellaneous cleanup, made code a bit more legible