integrating halbuilder and adding some tests
some additional cleanup