Fixed exception being thrown when first category is empty, also refactored MainForm a bit