Code cleanun + use more python idioms