weights proper integer fix with some refactoring