Refactoring various stuff