Update by lev76g

These are some fixes from lev76g on AquaFlame.NET forums. Thank you.