some fixes and added a couple new helper functions