Fixes by @cristiandouce 's suggestion