cleaned code + few bug fixes