Added remaining functionality and bug fixes