Small improvements on storing, fix bug