Refactor, add initial docs

Slightly better docs, still work in progress, please post questions inline and will improve this PR.

Also adds gii code generator for resources