Improve error control. Remove dirty prints