initial modifications from magcius branch