Fixed minor bugs - cleaned code