Transform/captured vars

Review by @DarkDimius