[TASK] Cleanups, code improvements and tests