Fixed bug with refraction. Not quite working perfectly yet but roughly functional.