Fixed NPE
Converted some more code to use dataset interface