Fixed (#49) and further work on (#40)