Fixes issue #998.

Fixes multiple issues with the way PR #997 was implemented. 
@TShapinsky if there're not saved preferences, the method would have attempted to parse `null` as an Integer.