Added more error trapping and printing. Come on GCC 4.6!