Varios refactors