Fixes courtesy of mako