Docs rewritten, minor bugs fixed