Rework code structure into something more sensible. I did not like the previous structure at all.