Fixes according to Paul's suggestion