Cleaned up code and it seems that it is actually working now!