code clean up and fix potential bug (line 298)
be anal. put mod constants in main mod file