Cleaned code, made functions inline,