Fixes critical bugs in pr5.2