Seriously rewrite and fix storage functions.