Fixing indices etc to make work with CMs code