general formatting fixes, made code more concise