Refactored weak code, still to refactor much more