Fixed access voilation bugs.