Refactor & improvements