Refacts and fixes