improve module structure; add global.hrl for global definitions