Refactored, cleaned and fixed.
Merge branch 'general_fixes' into develop