Cleaned up some misc. code