centralize constants and bug fix.