misc refine, removed magic numbers