fix: codebase improvements and fixed bugs.