Major rewrite and documentation update!