Tested basic math fcns + some optimization