some more changes

Improving readability and easier to extend. Also adding a bit of documentation.

It might be a good idea to push the usefull changes back to 0 a.d..