fixed more stuff and added scheduler code