Fixes for #15 and #3

Fixes for #15 and #3, I hope everything is working this time...

// Olof