cleanup & bug fixes