initial implementation, buggy but it works ^^

initial implementation.
it is buggy, can you easily bug it up by stress-testing it n stuff, and i'm not sure how to do it perfectly... but this is pretty good, it mostly works ^^