couple of tweaks and added error handling to packet parser