Fix for CRAFTERCMS-512 and CRAFTERCMS-515