fixes + added 'extern' / inline to optimize output
fixed Promise