Fix some issues (#42, #44, #45, #46)