Complete re-write with numerous features, bug fixes and styles added