some bug fixes, still broken tests