Bugfixes

@maisaraFarahat , please review.