This is hacky and might be just covering the bug. Needs careful review.