Fixed issues mentioned in https://review.openbloomberg.com/D24
fixed issues from https://review.openbloomberg.com/D25
fixes according to https://review.openbloomberg.com/D26#comment-1
fixed issues from https://review.openbloomberg.com/D27