Added basic functionality and fixed some bugs