Add some asserts, fix val not being valid, needs to be def