added dist and some minor refactoring