Fixed bugs in emod