Refactored stuff

Makes it pretty trivial to add new formats. For most things you just need to write the correct regex and call the right function.