finally fixed book cleanup

todo: maybe add vacuum after cleanup