Misc code fixes & clean