Various changes + bug fixes