Fixed several bugs in ERAT