Added functionality + code refactioring.