Several fixes according to the review comments