*: general improvements and refactoring