Added initial implementation of parsing, fixed some faulty code