Merging changes from tasjo repository

This is the first phase of merging changes from the tasjo repository.
Integration with the new php scripts is still to be done.