Improved error logging; deleted cruft; fixed stats bug