Fix: #1724 + #1716

Solution taken from: http://archive.rebeccablacktech.com/g/thread/S43293110#p43294150