Recent commits from Dano

Several useful changes in code