Still bugfixing and error-checking