Updating code to work with new maltab releases and some tidying up.