Added functionality and removed bugs.