Initial version

Working first version, still lacks some testing.