Bogdan's version
little fixes