Fixed bugs from 2.2.2.2 and did some better error handling