Support for subprojects and conversion to class

Also, many, many changes...

This script probably need a clean up.