Some shitty code works. Will be replaced with nice code tomorrow.