Rewritten a lot of stuff, added Snippet class with promises.