metric bug fixed, various refactories