Fixing some bugs and some performance improvements for the high level runtime