some bug fixes.
starting implementation of error-checking.
.