Few adaptations and bug fixes.