Moved everything inside the document ready function. White screen bug is probably fixed now