Fixed some bugs in reflection/refraction

reflection/refraction almost done. need to test some things before
completion.
reorganized

split reflection/refraction into two functions. Fixed recursion.
Fixed reflection and refraction, multithreading is broken