Added some fixes

courtesy of /u/kemitche