Rewritten core code for easier additional features. Much easier to understand.