added missing variables
added function prototypes
changed vectors to pointer
pointer handling improved
first compiling version