Code cleanub and fixes