add logging + bug fixes