Made use of the new commands BI made available as well as improved some code in places.