Tried to adapt according to Ben's review comments.