there are some bugs in here, but i need to commit this since i'm going to be switching machines tomorrow...