Formatting features

Major rehaul of code. More elegant recursion, more features!