Updated systme callback code and other small bug fixes