cleaned up code; fixed logged-in ls/cd problem