Fix for for bug#45 and bug#34