ported changes from omegalib 4.3 by Arthur Nishimoto