inline functions + some minor changes