Reorder pronterface code into meaningful sections

These 2100 lines of code were really a huge mess ><
Also rename some functions.