Big commit. Will try to do atomic ones in the next changes.