incorporated various bugfixes from jos version