much change on mab.lua and also refactor others